#!/usr/bin/env python
# -*- coding:UTF-8 -*-
# zhouyi 6098550@qq.com

import mi_server
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return 'This is the mi machine api.flask restful.'

@app.route('/v1/machine_uuid')
def machine_uuid():
    return '1234567890'

@app.route('/v1/weight/<int:no>')
def get_weight(no):
    return mi_server.GetWeight(no)

@app.route('/v1/start_work')
def start_work():
    return mi_server.StartWork()

@app.route('/v1/stop_work')
def stop_work():
    return mi_server.StopWork()

@app.route('/v1/abort_work')
def abort_work():
    return mi_server.AbortWork()

@app.route('/v1/work_status')
def work_status():
    return mi_server.WorkStatus()

if __name__ == '__main__':
    app.debug = True
    app.run(host='0.0.0.0', port=mi_server.config.flask_config.port, threaded=True)
    #app.run(host='0.0.0.0', port=config.flask_config.port)
